# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=ssrf-proxy
pkgver=293.e79da7a
pkgrel=19
pkgdesc='Facilitates tunneling HTTP communications through servers vulnerable to Server-Side Request Forgery.'
groups=('blackarch' 'blackarch-proxy' 'blackarch-tunnel')
arch=('any')
url='https://github.com/bcoles/ssrf_proxy'
license=('MIT')
depends=('ruby' 'ruby-bundler' 'libxslt')
makedepends=('git' 'ruby-rdoc')
source=("$pkgname::git+https://github.com/bcoles/ssrf_proxy.git"
        'ssrf_proxy.gemspec.patch')
install="$pkgname.install"
sha512sums=('SKIP'
            '201628bf889fc680ef5271b808ebdc27539815d0ff206b538c585ad8eaa3a60427debf130ed35268a107daf872c147132035fea0e29f54528bc86bd5a0a11178')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  patch -p1 < ssrf_proxy.gemspec.patch
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
  install -Dm 644 LICENSE.md "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec bundle exec ./bin/$pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"

  touch "$pkgdir/usr/share/$pkgname/Gemfile.lock"
}

